package singleton;

/**
 * 懒汉式
 * 双重检查+锁
 *
 * @author yangyang
 * @date 2017/8/25 18:18
 * @email kekecany@163.com
 */
public class DoubleCheckWithLock {

    private static DoubleCheckWithLock singleton = null;

    private DoubleCheckWithLock() {}

    public static DoubleCheckWithLock getInstance() {
        if (singleton == null) {
            synchronized (DoubleCheckWithLock.class) {
                if (singleton == null) {
                    singleton = new DoubleCheckWithLock();
                }
            }
        }
        return singleton;
    }
}
